<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="commn/base.css" />
		<link rel="stylesheet" type="text/css" href="css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="Hui-iconfont/1.0.8/iconfont.css" />
		<style type="text/css">
			body {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				width: 100%;
			}
			
			.index {
				min-width: 240px;
			}
			
			.top {
				display: -webkit-box;
				width: 100%;
				height: 40px;
				background-color: #0F88EB;
			}
			
			.top>span {
				line-height: 40px;
				text-indent: 1em;
				color: white;
				display: -webkit-box;
				font-size: 18px;
				font-weight: bold;
				-webkit-box-flex: 1;
			}
			
			.back {
				color: white;
				font-size: 18px;
				margin-left: 15px;
				line-height: 40px;
			}
			
			.content {
				margin-top: 5px;
				width: 100%;
				height: 300px;
				outline: none;
				border: 1px solid #EEEEEE;
			}
			
			.send {
				height: 40px;
				width: 100px;
				color: white;
				margin-left: 5%;
				font-size: 14px;
				border: 1px solid #0F88EB;
				background-color: #0F88EB;
				outline: none;
				border-radius: 40px;
			}
		</style>
	</head>

	<body>
		<div class="index">
			<div class="top">
				<i class="back Hui-iconfont Hui-iconfont-slider-left" @click="back()"></i>
				<span>回答</span>
			</div>
			<div class="home_content">

				<textarea class="content" placeholder='输入问题的回答.....' v-model="text"></textarea>
				<p><input type="button" @click="pinglun()" class="send" value="提交回答" /></p>
			</div>
		</div>
		<script src="js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var newVue = new Vue({
				el: "body",
				data: {
					vueindex: "",
					text: ""
				},
				methods: {
					back: function() {
						location.href = "questions.html?id=" + newVue.vueindex;
					},
					pinglun: function() {
						send(this.text)
					}
				}
			})
			var ss;
			var dd;
			var index;
			var reg = new RegExp("(^|&)" + "id" + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if(r != null) {
				console.log(unescape(r[2]));
				index = unescape(r[2]);
				newVue.vueindex = unescape(r[2]);
			} else {
				console.log(null);
			};
			//评论部分
			var year = new Date();
			var nian = year.getFullYear();
			var yue = (year.getMonth() + 1) < 10 ? "0" + (year.getMonth() + 1) : year.getMonth() + 1;
			var day = year.getDate() < 10 ? "0" + year.getDate() : year.getDate();
			var str1 = nian + "-" + yue + "-" + day;

			function send(text) {

				var ss;
				var dd;
				$.ajax({
					type: 'get',
					//async:false,
					url: "http://v2.mashupcloud.cn/developer/auth.do",
					data: {
						appkey: 'FvWrIYOQoTUYVbscUNQoQAVqsLnZqKEN',
						appsecret: 'ugCfcSmyLkcbCGfIuFOPEgTgPQPbyJSE'

					},
					success: function(json) {
						//		            console.log(json);
						ss = JSON.parse(json)[1];
						dd = JSON.parse(json)[2];
						console.log('获得token成功');
						$.ajax({
							type: 'get',
							url: "http://v2.mashupcloud.cn/SQL/into_p/",
							data: {
								appid: dd,
								token: ss,
								name: 'into_p',
								_v1: index,
								_v2: text,
								_v3: sessionStorage.getItem("id"),
								_v4: str1
							},
							success: function(json) {
								console.log(JSON.parse(json));
								alert("回答成功");
								location.href = "questions.html?id=" + newVue.vueindex;

							},
							error: function(json) {
								console.log("err:" + json);
							}
						});
					},
					error: function(json) {
						console.log("err:" + json);
					}
				});

			};
		</script>
	</body>

</html>